home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm_msc1.arc / DOSSUB2I.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  5KB  |  176 lines

  1. ; DOSSUB2I - general dos subroutine interface for interpretive BASIC
  2. ; Copyright 1983 Data Base Decisions
  3. ; CALL DOSSUB2I(STACK$,RETCD%,INTNO%,ES%,SI%,DI%,AH%,AL%,BH%,BL%,CH%,CL%,DH%,DL%)
  4. ; STACK$ is the stack area
  5. ; RETCD% is the error return code (0 if no error)
  6. ; INTNO% is the interrupt number (0 to 255)
  7. ; ES% is the argument corresponding to register ES
  8. ; SI% is the argument corresponding to register SI
  9. ; DI% is the argument corresponding to register DI
  10. ; AH% is the argument corresponding to register AH
  11. ; AL% is the argument corresponding to register AL
  12. ; BH% is the argument corresponding to register BH
  13. ; BL% is the argument corresponding to register BL
  14. ; CH% is the argument corresponding to register CH
  15. ; CL% is the argument corresponding to register CL
  16. ; DH% is the argument corresponding to register DH
  17. ; DL% is the argument corresponding to register DL
  18.  
  19. cseg    segment para public 'code'
  20. public    dossub2i
  21. dossub2i proc far
  22.     assume cs:cseg,ds:nothing,ss:nothing,es:nothing
  23.     push bp
  24.     mov bp,sp
  25.  
  26. p10:                ; use passed stack
  27.     mov di,sp        ; save orig sp
  28.     mov si,[bp+32]        ; point to stack$ arg
  29.     mov al,[si]        ; get length
  30.     mov ah,0
  31.     inc si
  32.     add ax,[si]        ; add start addr
  33.     dec ax            ; down by 1
  34.     mov sp,ax        ; new sp
  35.     push di         ; save orig sp on new stack - push 0
  36.  
  37. p20:                ; temporarily change fatal error vector
  38.     push ds         ; push 1
  39.     push es         ; push 2
  40.     xor ax,ax
  41.     mov ds,ax
  42.     mov ax,[ds:90h]     ; get fatal error ip
  43.     push ax         ; save ip - push 3
  44.     mov ax,[ds:92h]     ; get fatal error cs
  45.     push ax         ; save cs - push 4
  46.     call p25        ; get ip - push 5a
  47.  
  48. p25:
  49. a25    equ this byte
  50.     pop bx            ; ip in bx - pop 5a
  51.     add bx,a50-a25
  52.     mov ds:90h,bx        ; ip of vector
  53.     push cs         ; set fatal error cs - push 5b
  54.     pop ax            ; set ds to cs - pop 5b
  55.     mov ds:92h,ax        ; cs of vector
  56.     push es         ; push 5c
  57.     pop ds            ; restore ds - pop 5c
  58.  
  59. p30:                ; set registers for call
  60.     mov si,[bp+20]        ; point to ah argument
  61.     mov ah,[si]
  62.     mov si,[bp+18]        ; point to al argument
  63.     mov al,[si]
  64.     mov si,[bp+16]        ; point to bh argument
  65.     mov bh,[si]
  66.     mov si,[bp+14]        ; point to bl argument
  67.     mov bl,[si]
  68.     mov si,[bp+12]        ; point to ch argument
  69.     mov ch,[si]
  70.     mov si,[bp+10]        ; point to cl argument
  71.     mov cl,[si]
  72.     mov si,[bp+8]        ; point to dh argument
  73.     mov dh,[si]
  74.     mov si,[bp+6]        ; point to dl argument
  75.     mov dl,[si]
  76.     mov si,[bp+22]        ; point to di argument
  77.     mov di,[si]
  78.     mov si,[bp+26]        ; point to es argument
  79.     push ax         ; push 5d
  80.     mov ax,[si]        ; es arg in ax
  81.     mov es,ax
  82.     pop ax            ; pop 5d
  83.     mov si,[bp+24]        ; point to si argument
  84.     mov si,[si]
  85.  
  86. p40:                ; set up for call
  87.     push ax         ; push 5e
  88.     push bx         ; push 6
  89.     mov bx,[bp+28]        ; point to interrupt no
  90.     mov al,[bx]        ; interrupt in al
  91.     call p45        ; push 7
  92.  
  93. p45:
  94. a45    equ this byte
  95.     pop bx            ; ip in bx - pop 7
  96.     add bx,a46-a45+1
  97.     mov cs:[bx],al        ; set interrupt
  98.     pop bx            ; pop 6
  99.     pop ax            ; pop 5e
  100.     push bp         ; save bp - bios bug - push 5f
  101.     clc            ; clear carry
  102.  
  103. a46    equ this byte
  104.     int 00h         ; overlaid by intno%
  105.     jc p48            ; dos 2.0 error
  106.     jmp short p60        ; skip err control
  107.  
  108. p48:                ; dos 2.00 error
  109.     pop bp            ; pop 5f
  110.     mov ah,1        ; indicate dos 2.0 error
  111.     mov si,[bp+30]        ; point to RETCD%
  112.     mov [si],ax        ; save error
  113.     jmp short p70        ; bail out
  114.  
  115. p50:                ; handle fatal error
  116. a50    equ this byte
  117.     sti            ; interrupts back on
  118.     mov ax,di        ; get error code
  119.     mov ah,0        ; error in al
  120.     add sp,20        ; skip unneeded stack
  121.     pop ds
  122.     pop es
  123.     add sp,6        ; skip rest of stack
  124.     pop bp            ; restore bp - bios bug - pop 5f
  125.     mov si,[bp+30]
  126.     mov [si],ax        ; return error
  127.     jmp short p70        ; restore orig vector
  128.  
  129. p60:                ; return register values
  130.     pop bp            ; restore bp - bios bug - pop 5f
  131.     push si         ; save for later - push 5g
  132.     mov si,[bp+20]        ; point to ah argument
  133.     mov [si],ah
  134.     mov si,[bp+18]        ; point to al argument
  135.     mov [si],al
  136.     mov si,[bp+16]        ; point to bh argument
  137.     mov [si],bh
  138.     mov si,[bp+14]        ; point to bl argument
  139.     mov [si],bl
  140.     mov si,[bp+12]        ; point to ch argument
  141.     mov [si],ch
  142.     mov si,[bp+10]        ; point to cl argument
  143.     mov [si],cl
  144.     mov si,[bp+8]        ; point to dh argument
  145.     mov [si],dh
  146.     mov si,[bp+6]        ; point to dl argument
  147.     mov [si],dl
  148.     pop ax            ; get returned si in ax - pop 5g
  149.     mov si,[bp+24]        ; point to si argument
  150.     mov [si],ax
  151.     mov ax,es        ; get returned es in ax
  152.     mov si,[bp+26]        ; point to es argument
  153.     mov [si],ax
  154.     mov si,[bp+22]        ; point to di argument
  155.     mov [si],di
  156.  
  157. p70:                ; reset fatal error vector
  158.     xor ax,ax
  159.     mov ds,ax
  160.     pop ax            ; re-set fatal error vector - pop 4
  161.     mov ds:92h,ax        ; restore original cs
  162.     pop ax            ; pop 3
  163.     mov ds:90h,ax        ; restore original ip
  164.     pop es            ; pop 2
  165.     pop ds            ; pop 1
  166.  
  167. p80:                ; return to caller
  168.     pop di            ; get orig sp - pop 0
  169.     mov sp,di        ; back to orig stack
  170.     pop bp            ; return to caller
  171.     ret 28
  172.  
  173. dossub2i endp
  174. cseg    ends
  175.     end
  176.